from selenium import webdriver
from selenium.webdriver.common.by import By
import time

class TestCase:
    def __init__(self):
        # 初始化对象属性
        self.driver = webdriver.Chrome()

    def get_so(self):
        # 请求so
        self.driver.get('http://www.so.com')

        # 搜索框输入内容
        time.sleep(2)
        self.driver.find_element(By.ID, 'input').send_keys('天气预报')

        # 点击百度一下
        time.sleep(2)
        self.driver.find_element(By.ID, 'search-button').click()

    def quit(self, seconds=2):
        time.sleep(seconds)
        self.driver.quit()

if __name__ == '__main__':
    case = TestCase()
    case.get_so()
    case.quit()